package cn.glutnn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.glutnn.entity.Orders;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;


/**
 * 订单表(Orders)表数据库访问层
 *
 * @author msh
 * @since 2024-12-12 16:54:12
 */
public interface OrdersMapper extends BaseMapper<Orders> {


    @Select("SELECT COUNT(*) FROM orders " +
            "WHERE business_id = #{businessId} " +
            "AND order_state = 2 " +
            "AND orders.order_date >= #{monthAgo}")
    Integer countMonthlySales(@Param("businessId") Integer businessId,
                              @Param("monthAgo") LocalDateTime monthAgo);
}

